Ext.define('Platform.plugin.grid.ColumnsBuilder', {
    extend : 'Ext.AbstractPlugin',
    alias : [ 'plugin.grid.columnsbuilder' ],

    requires : [],

    uses : [],

    config : {},

    defaultConfig : {

    },

    constructor : function(cfg) {
	    var me = this;
	    cfg = cfg || {};

	    console.log(cfg.model, me.model);

	    me.callParent([ Ext.apply(me.defaultConfig, cfg) ]);
    },

    init : function(cmp) {
	    var me = this, columns = [], fields;

	    if (me.model) {
		    if (Ext.isString(me.model)) {
			    fields = Ext.create(me.model).fields;

			    fields.each(function(item, index, length) {
				    columns[index] = {
				        text : 'Unknown',
				        dataIndex : item.name
				    };
			    });

			    cmp.columns = columns;
		    }
	    } else {
		    Ext.Msg.alert('插件错误', me.getName());
	    }

	    console.log(cmp);
    },

    destroy : function() {
	    Ext.destroy(this);
    },

    enable : function() {
	    this.callParent();
    },

    disable : function() {
	    this.callParent();
    }

});